#pragma once

#include "basictypes.h"
#include "file.h"

#include "third_party/scoped_ptr.h"


namespace bl{

class StreamReader
{
public:
	StreamReader(void);
	~StreamReader(void);

	static const uint32 _BufferSize;

	bool Init(const tchar* fileName);

	enum Encoding { AsciiEncoding, UTF8Encoding, Unicode16LEEncoding, Unicode16BEEncoding};

	Encoding ContentEncoding() const;

	bool ReadLineAnsi(std::string& line);
	bool ReadLine(std::wstring& line);

private:
	uint32 GetFileBufferSize() const { return file_buffer_size_;}

	uint32 file_buffer_size_;
	uint32 current_pos_;
	uint32 file_buffer_count_ ;
	bool last_is_return_carriage_;

	Encoding encoding_;

	File file_;
	scoped_array<uint8> file_buffer_;
};




} // End of BL